<template>
    <div class="streaming">
        <div class="SearchResult-content">
            <div class="SearchResultLive">


                <div v-infinite-scroll="loadMore" infinite-scroll-disabled="loading" infinite-scroll-distance="20">

                    <div class="NormalRoomItem" v-for="(item ,index) in arr" :key="index" >
                        <div class="NormalRoomItem-show" @click="fun(item.roomId)" >
                            <div class="NormalRoomItem-showImg">
                                <img :src="item.roomSrc" alt="">
                            </div>
                            <div class="NormalRoomItem-showHot">
                                <i class="NormalRoomItem-showHotIcon"></i>
                                <span class="NormalRoomItem-showHotNum">{{item.hn}}</span>
                            </div>
                            <div class="NormalRoomItem-showLive"></div>
                            <div class="NormalRoomItem-showAnchor">
                                <i class="NormalRoomItem-showAnchorIcon"></i>
                                <span class="NormalRoomItem-showAnchorName">{{item.nickname}}</span>
                            </div>
                        </div>
                        <div class="NormalRoomItem-title">{{item.roomName}}</div>
                    </div>

                </div>
                <!-- <div class="bx">下拉加载。。。</div> -->

            </div>


        </div>

        <!-- <div class="box"></div> -->
    </div>

</template>
<script>
    // 按需引入部分组件
    import { InfiniteScroll } from 'mint-ui';
    export default {
        name: 'streaming',
        data() {
            return {
                arr: [],
                num: [],
                zive: '',
                show: 'false',
                tow: '20',
                int: '1',
                flag: true,
                lang: ''
            }
        },
        created() {
            this.num = this.$route.query.index
            this.zive = encodeURI(this.$route.query.zive)
            this.send(this.zive, this.num, this.tow)
        },
        methods: {
            send(zive, num, tow) {
                this.$http.get(`/api/search/getData?sk=${zive}&type=${num}&sort=1&limit=20&offset=${tow}`).then(res => {
                    this.arr = [
                        ...this.arr,
                        ...res.data.data.live
                    ]
                }).catch(res => {
                    this.flag = false
                })
            },
            loadMore() {
                if (this.flag) {
                    this.flag = false
                    this.int++
                    this.tow = 20 * this.int
                    this.send(this.zive, this.num, this.tow)
                }
            },
            fun(rid) {
                this.$router.push({
                    path: '/detlete',
                    query: {
                        rid: rid
                    }
                })
            },
        },
    }
</script>
<style scoped>
    .SearchResult-content {
        position: absolute;
        top: -0px;
        left: 0;
        bottom: 0;
        width: 100%;
        -webkit-overflow-scrolling: touch;
        background: #fff;
    }

    .SearchResultLive {
        padding-bottom: 10px;
        width: 100%;
    }

    .SearchResultLive-content {
        box-sizing: border-box;
        width: 100%;
        background: #fff;
        padding: 0px 0 0 5px;
    }

    .NormalRoomItem {
        float: left;
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
        box-sizing: border-box;
        padding: 20px 5px 5px 0;
        width: 50%;
        margin-top: 116px;
    }

    .NormalRoomItem-show {
        position: relative;
        -webkit-border-radius: 4px;
        -moz-border-radius: 4px;
        border-radius: 4px;
        width: 100%;
        background: url(https://shark2.douyucdn.cn/front-publish/m-douyu-v3-master/assets/images/list-item-def-thumb_b10bbe8.png) no-repeat;
        -webkit-background-size: 100% 100%;
        -moz-background-size: 100% 100%;
        background-size: 100% 100%;
    }

    .NormalRoomItem-showImg {
        position: absolute;
        top: 0;
        left: 0;
        z-index: 1;
        -moz-border-radius: 4px;
        border-radius: 4px;
        width: 100%;
        height: 100%;
    }

    .NormalRoomItem-showImg img {
        -moz-border-radius: 4px;
        border-radius: 4px;
        width: 100%;
    }

    .NormalRoomItem-showHot {
        position: absolute;
        top: 0;
        left: 0;
        z-index: 10;
        display: -webkit-box;
        display: -webkit-flex;
        display: -moz-box;
        display: -ms-flexbox;
        display: flex;
        -webkit-box-pack: end;
        -webkit-justify-content: flex-end;
        -moz-box-pack: end;
        -ms-flex-pack: end;
        justify-content: flex-end;
        -webkit-box-align: center;
        -webkit-align-items: center;
        -moz-box-align: center;
        -ms-flex-align: center;
        align-items: center;
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
        box-sizing: border-box;
        padding-right: 5px;
        width: 100%;
        height: 18px;
        background: url(https://shark2.douyucdn.cn/front-publish/m-douyu-v3-master/assets/images/bg-shadow_e60f214.png) no-repeat;
        -webkit-background-size: 100% 100%;
        -moz-background-size: 100% 100%;
        background-size: 100% 100%;
        -webkit-border-radius: 4px 4px 0 0;
        -moz-border-radius: 4px 4px 0 0;
        border-radius: 4px 4px 0 0;
    }

    .NormalRoomItem-showHotIcon {
        display: block;
        margin-right: 3px;
        width: 11px;
        height: 11px;
        background: url(https://shark2.douyucdn.cn/front-publish/m-douyu-v3-master/assets/images/hotnum_6b05e5d.png) no-repeat;
        -webkit-background-size: 100% 100%;
        -moz-background-size: 100% 100%;
        background-size: 100% 100%;
    }

    .NormalRoomItem-showHotNum {
        display: block;
        height: 100%;
        line-height: 18px;
        font-size: 10px;
        color: #fff;
    }

    .NormalRoomItem-showLive {
        position: absolute;
        left: 0;
        top: 0;
        z-index: 20;
        width: 56px;
        height: 16px;
        background-image: url(https://shark2.douyucdn.cn/front-publish/m-douyu-v3-master/assets/images/playing_9f3b01a.png);
        background-repeat: no-repeat;
        -webkit-background-size: 100% 100%;
        -moz-background-size: 100% 100%;
        background-size: 100% 100%;
    }

    .NormalRoomItem-showAnchor {
        position: absolute;
        left: 0;
        bottom: -102px;
        z-index: 10;
        display: -webkit-box;
        display: -webkit-flex;
        display: -moz-box;
        display: -ms-flexbox;
        display: flex;
        -webkit-box-pack: start;
        -webkit-justify-content: flex-start;
        -moz-box-pack: start;
        -ms-flex-pack: start;
        justify-content: flex-start;
        -webkit-box-align: center;
        -webkit-align-items: center;
        -moz-box-align: center;
        -ms-flex-align: center;
        align-items: center;
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
        box-sizing: border-box;
        padding: 0 5px;
        -webkit-border-radius: 0 0 4px 4px;
        -moz-border-radius: 0 0 4px 4px;
        border-radius: 0 0 4px 4px;
        width: 100%;
        height: 18px;
        background: -webkit-linear-gradient(transparent, rgba(0, 0, 0, .8));
        background: -webkit-gradient(linear, left top, left bottom, from(transparent), to(rgba(0, 0, 0, .8)));
        background: -moz- oldlinear-gradient(transparent, rgba(0, 0, 0, .8));
        background: -o-linear-gradient(transparent, rgba(0, 0, 0, .8));
        background: linear-gradient(transparent, rgba(0, 0, 0, .8));
    }

    .NormalRoomItem-showAnchorIcon {
        display: block;
        width: 11px;
        height: 12px;
        margin-right: 3px;
        background: url(https://shark2.douyucdn.cn/front-publish/m-douyu-v3-master/assets/images/iconfont-wo_fdcada2.png) no-repeat;
        -webkit-background-size: 100% 100%;
        -moz-background-size: 100% 100%;
        background-size: 100% 100%;
    }

    .NormalRoomItem-showAnchorName {
        display: block;
        -webkit-box-flex: 1;
        -webkit-flex: 1;
        -moz-box-flex: 1;
        -ms-flex: 1;
        flex: 1;
        height: 18px;
        line-height: 18px;
        font-size: 10px;
        color: #fff;
        -o-text-overflow: ellipsis;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .NormalRoomItem-title {
        z-index: 9;
        position: relative;
        bottom: -110px;
        left: 0;
        overflow: hidden;
        height: 12px;
    }
</style>